home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1998 January: Mac OS SDK / Dev.CD Jan 98 SDK2.toast / Development Kits (Disc 2) / ScriptX / Documentation / Code Examples from Docs / langguid / chap_05 / xmpl_05.sx < prev    next >
Encoding:
Text File  |  1996-05-21  |  368 b   |  18 lines  |  [TEXT/ttxt]

  1. --<<<
  2. -- Kaleida Labs, Inc.
  3. -- Field Guide to the ScriptX Language
  4. -- chapter 5, example 5
  5.  
  6. -- using apply to call functions
  7.  
  8. function addEmUp #rest args -> (
  9.     local sum := 0
  10.     for i in args do sum := sum + i
  11.     return sum
  12. )
  13. global a := #(1,4,9,16)
  14. global b := 1 to (a.size)
  15. myArgs := merge a b
  16. -- use apply to call function with rest arguments
  17. apply addEmUp myArgs
  18. -->>>